﻿Imports System.Windows.Forms
Imports EguSoc_Dll.EguSoc_Dll
Imports EguSoc_Dll
Imports JanuControls

Public Class MDI_EA
    Private TA_Socios As New Socios_TableAdapter
    Private Linea_Error As Integer
    Private Sub MDI_EA_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            'TmrRetardo.Enabled = True
            'TmrRetardo.Interval = 5000
            'TmrRetardo.Start()
            'TmrRetardo.Enabled = False

            Carga_Conexion_Archivo()
            TA_Socios.Fill(DSEA.Socios)
            SociosCargado1.Refrescar_Datos()

        Catch ex As Exception
            MessageBox.Show("En la carga " & Linea_Error & " - " & ex.Message)
        End Try
    End Sub

    Private Sub TSBSocios_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBSocios.Click
        Try
            Dim Grado_Socio As String = ""
            Dim Pass As String = ""

            If DSEA.Socios.Count = 0 Then
                Dim Socios As New FES_Socios(Pass, Grado_Socio)
                Socios.ShowDialog()
            ElseIf Valida_Socio(Grado_Socio, Pass) Then
                Dim Socios As New FES_Socios(Pass, Grado_Socio)
                Socios.ShowDialog()
            End If

            TA_Socios.Fill(DSEA.Socios)
            SociosCargado1.Refrescar_Datos()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub TSBAdmon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBAdmon.Click
        Try
            Dim Grado_Socio As String = ""
            Dim Pass As String = ""

            If Valida_Socio(Grado_Socio, Pass) Then
                Dim Gestion As New FES_Gestion(Grado_Socio)
                Gestion.ShowDialog()
            End If

            TA_Socios.Fill(DSEA.Socios)
            SociosCargado1.Refrescar_Datos()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub SociosCargado1_Cambia_Valor() Handles SociosCargado1.Cambia_Valor
        Try
            Select Case Valida_PIN_Socio(SociosCargado1.Devuelve_Valor)
                Case -1
                    Dim Sobres As New FES_Sobres(SociosCargado1.Devuelve_Valor, "C")

                    Sobres.ShowDialog()

                    TA_Socios.Fill(DSEA.Socios)
                    SociosCargado1.Refrescar_Datos()
                Case 0
                    MessageBox.Show("PIN incorrecto", My.Settings.Cabezeras_Mensaje)
            End Select

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
        Try
            Me.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class
